import MathUtil from '@/MathUtil';
import MovementCommon from 'code/Core/Common/MovementCommon';
import UnitCommon from 'code/Core/Common/UnitCommon';
import AbilityBase from 'code/Scripts/Abilities/base/AbilityBase';
/**
 * 铁山靠
 **/
export default class WS_MeltalHillHit extends AbilityBase {
    static instance: WS_MeltalHillHit;
    constructor(id: string = 'Atsk') {
        super(id);
        WS_MeltalHillHit.instance = this;
        this.init();
        se.onUnitSpellEffect(this.onSpellEffect.bind(this), this.id);
    }
    init() {}
    cast<T extends Object = any>(tarX: number, tarY: number, source: unit, target: unit, data?: T): void {
        let lv = this.getAbilityLevel(source);
        let dmg = 125 * lv + UnitCommon.取攻击(source) * (0.66 + 0.32 * lv);
        DamageSystemInstance.applyAttackDamage(target, source, dmg, this.id);
        let ag = MathUtil.angleBetweenCoords(GetUnitX(source), GetUnitY(source), tarX, tarY);
        MovementCommon.hitFly({
            distance: 300,
            time: 0.5,
            target: target,
            caster: source,
            angle: ag,
            maxHeight: 0,
            onEnd: this.onEnd.bind(this),
            other: AddSpecialEffectTarget('Abilities\\Spells\\Human\\FlakCannons\\FlakTarget.mdl', target, 'origin'),
        });
        StunSystemIntance.stun(target, 0.5);
    }
    onSpellEffect() {
        this.cast(GetSpellTargetX(), GetSpellTargetY(), GetTriggerUnit(), GetSpellTargetUnit());
    }
    onEnd(p: HitFlyConfig) {
        DestroyEffect(p.other);
    }
}
